package controller;

import entity.Address;
import entity.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import util.ResponseResult;

import java.util.ArrayList;
import java.util.List;

/**
 * Author：汤小洋
 * Date：2022-11-28 13:38
 * Description：<描述>
 */
// @Controller
// @ResponseBody
@RestController
@RequestMapping("/ajax")
public class AjaxController {

    // @ResponseBody
    @RequestMapping("/test1")
    public User test1(){
        User user = new User();
        user.setId(1001);
        user.setUsername("tom");
        user.setPassword("123");
        user.setAge(20);
        user.setHeight(190.5);
        user.setAddress(new Address("江苏省","南京市"));

        System.out.println(user);
        return user;
    }

    @RequestMapping("/test2")
    public ResponseResult test2(){

        List<User> users = new ArrayList<>();
        users.add(new User(1,"aa","123",20,190.5,new Address("江苏省","南京市")));
        users.add(new User(2,"bb","123",20,190.5,new Address("江苏省","南京市")));
        users.add(new User(3,"cc","123",20,190.5,new Address("江苏省","南京市")));

        return ResponseResult.success(users);
    }


}
